//
//  main.cpp
//  指针传递给函数
//
//  Created by linjinzhu on 2017/7/11.
//  Copyright © 2017年 linjinzhu. All rights reserved.
//

#include <iostream>

using namespace std;

void changeValue(int *p);
double getAverage(int *p, int size);

int main(int argc, const char * argv[]) {

    int a = 0;
    changeValue(&a);
    cout << a << endl;

    int arr[3] = {1,2,3};
    cout << getAverage(arr, 3) << endl;

    return 0;
}


void changeValue(int *p)
{
    *p = 3;
}

double getAverage(int *p, int size)
{
    int sum = 0;
    for (int i=0; i<size; i++) {
        sum += p[i];
    }

    return double(sum) / size;
}
